import Vue from 'vue'
import 'es6-promise/auto'
import Vuex from 'vuex'
import App from './App'
import router from './router'
import Toastr from '@/assets/toastr/toastr.min'
import element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
//导入Toastr CSS样式
import '@/assets/toastr/toastr.min.css'

//定义提示框样式
Toastr.options={
  closeButton:true,
  positionClass:'toast-top-center',
  timeOut:1500
}



Vue.config.productionTip = false
const extend = Vue.prototype
//使用Vuex状态管理器
Vue.use(Vuex)
Vue.use(element)

extend.$post = fetch.post
extend.$get = fetch.get
extend.$form = fetch.form

const store = new Vuex.Store({
  state:{
      keyword:'',
      user:null,
      cartCount:null,
      cartProductId:null
  },
  mutations:{
    setKeyword(state,keyword){
      state.keyword = keyword
    },
    setUser(state,user){
      state.user = user
    },
    setCartCount(state,cartCount){
      state.cartCount = cartCount
    },
    setCartProductId(state,productId){
      state.cartProductId = productId
    }
  }
})


new Vue({
  el: '#app',
  store,
  router,
  components: {App},
  template:'<App/>'
})
